import { IPSModelObject } from '@ibiz/dynamic-model-api';

/**
 * 模型类型
 *
 * @author chitanda
 * @date 2021-05-14 16:05:30
 * @export
 * @enum {number}
 */
export const enum TypeMap {
  // 视图
  'app.view.IPSAppView' = 'IPSAppView',
  // 部件
  'control.IPSControl' = 'IPSControl',
}

/**
 * 根据模型给出类型
 *
 * @author chitanda
 * @date 2021-05-14 16:05:57
 * @export
 * @param {IPSModelObject} model
 * @return {*}  {string}
 */
export function modelType(model: IPSModelObject): string {
  if (model.instanceof(TypeMap['app.view.IPSAppView'])) {
    return TypeMap['app.view.IPSAppView'];
  }
  if (model.instanceof(TypeMap['control.IPSControl'])) {
    return TypeMap['control.IPSControl'];
  }
}
